<template>
  <div class="Entrance">
    <swiper :options="swiperOption">
      <swiper-slide v-for="(items,index) in icons" :key="index">
        <ul>
          <li v-for="(val,idx) in items" :key="idx"><img :src="val.imgUrl">
            <p class="Ent-text">{{val.title}}</p>
          </li>
        </ul>
      </swiper-slide>
      <div class="swiper-pagination" slot="pagination"></div>
    </swiper>


    <div class="box">
      <div class="location">
        <span class="iconfont">&#xe650;</span>
        定位失败
      </div>
      <div class="list">
        <span class="iconfont">&#xe629;</span>
        必游榜单
      </div>
    </div>
  </div>
</template>

<script>
  export default {
    name: "Entrance",
    props:["Entrance"],
    data() {
      return {
        swiperOption: {
          pagination: {
            el: ".swiper-pagination"
          }
        }
      }
    },
    computed: {

      /*             0               1
			* icons=[  [0,1,2,3,4,5,6,7] ,  [8,9,10,11]  ]
			* icons=[
				* [0,1,2,3,4,5,6,7],
                    0/8======0.x
					* 1/8====0.x
					*
					*
					* 7/8=====0.x
*
				* [8,9,10,11]
				*   8/8=====1.0
				*   9/8=====1.x
				*
				*   15/8=====1.x
				*
				*
				* 16/8======2
				*
				*
				* ]

			*  */
      icons() {
        let icons = []; //
        this.Entrance.forEach((val, index) => {
          // console.log(val,index)
          // console.log(Math.floor(index/8))
          let idx = Math.floor(index / 8)
          if (!icons[idx]) {
            // alert(11111)
            icons[idx] = []
            //  icons[0]=[]    icons[1]=[]

          }
          icons[idx].push(val)

        })

        // console.log(icons)

        return icons;
      }




    }


  }
</script>

<style scoped>
  .Entrance {
    width: 100%;
    font-size: 12px;

  }

  .Entrance ul {
    display: flex;
    flex-wrap: wrap;
    padding-bottom: 22px;
  }

  .Entrance li {
    width: 25%;
  }

  .Entrance li img {
    width: 70%;
    display: block;
    margin: 0 auto;
  }

  .Entrance .Ent-text {
    text-align: center;
  }

  .Entrance .box {
    border-top: 1px solid #E4E7EA;
    border-bottom: 1px solid #E4E7EA;
    margin: 5px 0;
    flex-wrap: nowrap;
  }

  .Entrance .box div {
    height: 50px;
    text-align: center;
    display: inline-block;
    width: 49%;
    line-height: 50px;
    box-sizing: border-box;
  }

  .Entrance .box .location {
    border-right: 1px solid #E4E7EA;
  }

  .Entrance .swiper-pagination {
    bottom: 2px;
  }
</style>
